import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart';

class ShareUnti {
  static Future share(String url, BuildContext context) {
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            shape: const RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.all(Radius.circular(4))),
            title: const Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('温馨提示',
                    style: TextStyle(
                        fontFamily: '思源黑体',
                        fontSize: 17,
                        fontWeight: FontWeight.w500))
              ],
            ),
            content: Container(
              constraints: const BoxConstraints(maxWidth: 238),
              child: Column(mainAxisSize: MainAxisSize.min, children: [
                const Text('监测到您当前设备为移动端设备，为了您更好的体验产品，可分享链接至PC端立即体验。',
                    style: TextStyle(
                        fontFamily: '思源黑体',
                        fontSize: 12,
                        fontWeight: FontWeight.w400)),
                const Padding(
                    padding: EdgeInsetsDirectional.only(top: 20)),
                FilledButton(
                    style: ButtonStyle(
                        fixedSize: MaterialStateProperty.all(const Size.fromWidth(238)),
                        backgroundColor:
                            MaterialStateProperty.all(const Color(0xff165DFF))),
                    onPressed: () {
                      Share.share(url);
                      // print('我想体验$homeLink');
                    },
                    child: const Text('分享链接',
                        style: TextStyle(
                          color: Color(0xffffffff),
                          fontFamily: '思源黑体',
                          fontSize: 16,
                          height: 1.4,
                        )))
              ]),
            ),
          );
        });
  }
}
